package org.javaboy.demo;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @author Lyh
 * @date 2024/2/8 0:50
 * @desciption:
 */
public class CustomDemo {
    public static void main(String[] args) {
        AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext();
        ConfigurableEnvironment env = ctx.getEnvironment();
        env.addActiveProfile("dev");
        env.addActiveProfile("prod");
        //此时再去设置配置类
        ctx.register(CustomJavaConfig.class);
        //开始初始化容器
        ctx.refresh();
        DataSource ds1 = ctx.getBean("prodDataSource",DataSource.class);
        System.out.println("ds1 = " + ds1);
    }
}
